<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

  defined('_JEXEC') or die('Retricted Access');
  
  global $jbconfig;  
?>
<script type="text/javascript">
	/* <![CDATA[ */   
    function submitbutton(pressbutton){
		if(pressbutton == "sendemail"){
			var sendmail = document.getElementById("sendmail");
			sendmail.style.display = "block";
		} else {
			form.task.value = pressbutton;
			form.submit();
		}
    }   
    /* ]]> */
</script>

<div id="jobboard-content">
<form action="<?php echo JRoute::_('index.php?option='. JBCOMNAME .'&view=jaapplications&layout=my-applications'); ?>" method="post" name="adminForm" id="adminForm">
	<?php if ($this->items){?>
		<div id="ja-applications-top">
			<div class="apply-top-left">
				<label><?php echo JText::_('Applications History')?></label>
			</div>
			<div class="apply-top-right">
				<label><?php echo JText::_('Created Date')?></label>
			</div>
		</div>
	
		<div id="ja-list-applications">
		<?php foreach ($this->items as $item){
			JFilterOutput::objectHTMLSafe( $item );
//			$item->message = str_replace('&#039;','\'',$item->message);
			$item->message = htmlspecialchars_decode ( $item->message );
		?>			
				<div class="ja-application clearfix">
				  <div class="ja-letter">
						<p>
							<?php $alias = JFilterOutput::stringURLSafe($item->job_id); ?>                    	
							<span class="apply-subject"><b><?php echo JFilterInput::_decode($item->subject, 'string')?></b> (<?php echo JText::_('Apply for Job')?>: <i><a href="<?php echo JRoute::_('index.php?option='. JBCOMNAME .'&view=jajobs&layout=jaview&cid[]='.$item->job_id_tmp.'&alias='.$alias.'&Itemid=1000')?>" id="goto_job_<?php echo $item->job_id_tmp?>"><?php echo $item->job_id; ?></a></i>)</span>:
							<span class="apply-body">
								<?php 
									if ($item->apply_type==3) echo $item->message;
									elseif($item->apply_type==2){
										echo JText::_('Information link');
										echo ' <a target="_blank" href="'.$item->inlinked.'">'.$item->inlinked.'</a>';
									}
								?>
							</span>						
						</p>
						 <?php if($item->attachment){ ?>
	                         <?php echo JText::_('Attached'); ?>:
	                         <?php 
			                       $ext = strtolower(substr($item->attachment, -3, 3));			                       
			                       if(!file_exists(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'images'.DS.'icons'.DS.'applications'.DS.$ext.'.gif')){
			                       		$ext = 'unknow';
			                       }
			                       $file_name = explode('/',$item->attachment);
		                       ?>
	                         <img src="components/com_jajobboard/images/icons/applications/<?php echo $ext?>.gif" alt="thumbnail"/>
	                         <a href ="#" onclick="location.href='<?php echo JRoute::_('index.php?option=com_jajobboard&amp;view=jaapplications&amp;task=download&amp;cid[]='.$item->id);?>'">
	                       		  <?php echo substr($file_name[count($file_name)-1],14);?>	                         
	                       	 </a> 
                      <?php }  ?>
					</div>
					<div class="apply-time">
						<?php echo date(str_replace('%', '', $jbconfig['general']->get('format_date')), strtotime($item->created_date));?>
					</div>
					<div class="application-button">
						<img title="<?php echo JText::_('Delete'); ?>" src="<?php echo JURI::base().'components/com_jajobboard/images/icon_delete.gif' ?>" alt="<?php echo JText::_('Delete'); ?>" />
		               &nbsp;
		                <a onclick="return confirm('<?php echo JText::_('Are you sure to delete this application?')?>')" href="<?php echo JRoute::_('index.php?option=com_jajobboard&view=jaapplications&task=jobseeker_remove&cid='.$item->id.'&Itemid='.JRequest::getInt('Itemid')); ?>">
		               		<span style="vertical-align: top !important;"><?php echo JText::_('Delete'); ?></span>
		               	</a>
					</div>  
				</div>
				
		<?php }?>
				<div align="center">
					<?php echo $this->pagination->getListFooter(); ?>
				</div>
		</div>
		
	<?php
	}
	else 
	{
		echo JText::_('You have not applied for any job yet!');
		
		?>
		<a class="button" href ="<?php echo JRoute::_('index.php?option='. JBCOMNAME .'&layout=jalist&view=jajobs&Itemid=131'); ?>" ><?php echo JText::_("Search and apply"); ?></a>
		<a class="button" href="javascript:window.history.go(-1);"><?php echo JText::_('Back'); ?></a>
		<?php
	}
	?>
	
	
	    <input type="hidden" name="option" value="<?php echo JBCOMNAME; ?>" />
	<input type="hidden" name="view" value="jaapplications" />
	<input type="hidden" name="layout" value="my-applications" />
    <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
	<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
    <input type="hidden" name="Itemid" value="<?php echo $this->Itemid; ?>" />
    <input type="hidden" name="limited" value="<?php echo $limited; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>	
 </form>
</div>